package com.dd.socket.handler;

import com.dd.entity.Flock;
import com.dd.entity.SocketMsg;
import com.dd.socket.MsgHandlerInterface;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.tio.core.Tio;
import org.tio.core.ChannelContext;

/**
 * 退群消息
 * 
 * @Author: 蛋蛋i
 * @Time:2017/11/28 10:56
 */
@IocBean
public class OutGroupMessageHandler implements MsgHandlerInterface {
	@Override
	public Object handler(String text, ChannelContext context) {
		SocketMsg msg = Json.fromJson(SocketMsg.class, text);
		Object body = msg.getBody();
		if (body != null) {
			Flock group = Json.fromJson(Flock.class, body.toString());
			Tio.unbindGroup(group.getId().toString(), context);
		}
		return null;
	}
}
